#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    string countAndSay(int n) {
        string ret = "1";
        while (--n)
        {
            int left = 0, right = 0;
            string tmp;
            while (right < ret.size())
                if (ret[left] == ret[right]) right++;
                else tmp += to_string(right - left), tmp += ret[left], left = right;
            ret = tmp + to_string(right - left) + ret[left];
        }
        return ret;
    }
};